<block name="header"></block>
<div id="main-container" class="container">
    <div class="row">
        <!--<block name="side">-->
        <!-- 左侧 nav
        ================================================== -->
        <!--<div class="span3 bs-docs-sidebar">-->
        <!--<block name="publish"></block>-->
        <!--</div>-->
        <!--</block>-->
        <block name="body"></block>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        $(window).resize(function () {
            $("#main-container").css("min-height", $(window).height() - 343);
        }).resize();
    })
</script>


<script src="http://webapi.amap.com/maps?v=1.3&key=4d2af0c35d5c5f1cd341ae323a1801d4"></script>
<script>
    //    map  by Cyan
    var map = new AMap.Map('map', {
        resizeEnable: true,
        zoom: 7,
        center:[113.261449,23.613679]
    });
    var count = 0;
    var points = [];
    var markers = [];
    var countMarker;
    var infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(0, -30)});
    supply();//默认为供应方地图
//    筛选出供应方订单
    function supply() {
        console.log('supply');
        clearMarkers();
        $.ajax({
            type: 'post',
            url: "{:U('Home/Order/getSupLocate')}",
            dataType: 'json',
            success: function (data) {
                points = eval(data.supply);
                console.log(points);
                for (count = 0; count < points.length; count++){
                    if (points[count].lang != ""){
                        countMarker = new AMap.Marker({
                            position: [points[count].lang, points[count].lat],
                            map: map
                        });
                        countMarker.content = "<a href='index.php?s=/Home/Info/detail/id/"+points[count].id+"'>"+ points[count].company + '</br>' + '联系电话:' + points[count].telphone + '</a>';
                        countMarker.on('click',markerClick);
                        markers.push(countMarker);
                    }
                }
            }
        })
    }
//    筛选出需求方订单
    function demand() {
        console.log('demand');
        clearMarkers();
        $.ajax({
            type: 'post',
            url: "{:U('Home/Order/getReqLocate')}",
            dataType: 'json',
            success: function (data) {
                points = eval(data.demand);
                console.log(points);
                for (count = 0; count < points.length; count++){
                    if (points[count].lang != ""){
                        countMarker = new AMap.Marker({
                            position: [points[count].lang, points[count].lat],
                            map: map
                        });
                        countMarker.content = "<a href='index.php?s=/Home/Info/detail/id/"+points[count].id+"'>"+ points[count].company + '</br>' + '联系电话:' + points[count].telphone + '</a>';
                        countMarker.on('click',markerClick);
                        markers.push(countMarker);
                    }
                }
            }
        })
    }
//    筛选出供应方和需求方已经完成的订单
    function finish() {
        console.log('finish');
        clearMarkers();
        $.ajax({
            type: 'post',
            url: "{:U('Home/Order/getFinLocate')}",
            dataType: 'json',
            success: function (data) {
                points = eval(data.finish);
                console.log(data);
                for (count = 0; count < points.length; count++){
                    if (points[count].lang != ""){
                        countMarker = new AMap.Marker({
                            position: [points[count].lang, points[count].lat],
                            map: map
                        });
                        countMarker.content = "<a href='index.php?s=/Home/Info/detail/id/"+points[count].id+"'>"+ points[count].company + '</br>' + '联系电话:' + points[count].telphone + '</a>';
                        countMarker.on('click',markerClick);
                        markers.push(countMarker);
                    }
                }
            }
        })
    }
    function clearMarkers() {
        infoWindow.close();
        map.remove(markers);
    }
    function markerClick(e) {
        infoWindow.setContent(e.target.content);
        infoWindow.open(map, e.target.getPosition());
    }
    // map end

    /*视频展区*/
    $('#demo1').videoUI({
        'autoHide': false,
        'volumeMedia': 1
    });
    /*视频展区end*/

</script>
<block name="script"></block>